home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / probots.arc / RUNNER.PR < prev    next >
Text File  |  1991-04-28  |  2KB  |  66 lines

  1.   PROCEDURE RUNNER;
  2.  
  3. {
  4.                             Based on C-Robot RUNNER
  5.  
  6.                                   by T. Harnish
  7.  
  8.                    "There I was with my back to the wall..."
  9.  
  10.                    Except for pre-positioning, everything is
  11.                    inline  code and has as few variables  as
  12.                    possible  to make this sucker as fast  as
  13.                    it can be. Some tweaking  of scan   width
  14.                    might   be   interesting.   The   obvious
  15.                    disadvantage of this guy is  that he  can
  16.                    never reach a 'bot running on  the  right
  17.                    edge, and could result in a draw if  they
  18.                    never get within 700 units of each other.
  19.  
  20.  
  21. }
  22.  
  23.     PROCEDURE GOTO(dest_x, dest_y : Integer); { go to lower left corner }
  24.     BEGIN
  25.       WHILE (distance(loc_x, loc_y, dest_x, dest_y) > 100) DO
  26.         IF (speed = 0) THEN drive(Angle_To(dest_x, dest_y), 100);
  27.  
  28.       drive(0, 0); {i.e., stop}
  29.       WHILE (speed > 0) DO {nothing-- i.e., slow down} ;
  30.     END; { End GoTO }
  31.  
  32.  
  33.   BEGIN { Main routine }
  34.  
  35.  
  36.     GOTO(0, 0); { Go to lower left corner }
  37.  
  38.     REPEAT { Main loop }
  39.       WHILE (loc_y < 850) DO BEGIN { Check for top }
  40.         drive(90, 100); { Go up }
  41.         IF (scan(0, 10) > 0) THEN { Look across }
  42.           cannon(0, scan(0, 10)); { Shoot if you see anything }
  43.         IF (scan(90, 10) > 0) THEN { Look where you are going }
  44.           cannon(90, scan(90, 10)); { Shoot if you see anything }
  45.         IF (scan(270, 10) > 0) THEN { Check your rear }
  46.           cannon(270, scan(270, 10)); { Shoot if you see anything }
  47.       END;
  48.       drive(90, 0); { Near top, slow down }
  49.       WHILE (speed > 50) DO ; { Wait for slow to 50 }
  50.  
  51.       WHILE (loc_y > 150) DO BEGIN { Check for bottom }
  52.         drive(270, 100); { Go down, if you'll pardon the expression }
  53.         IF (scan(0, 10) > 0) THEN { Look across }
  54.           cannon(0, scan(0, 10)); { Shoot, as before }
  55.         IF (scan(270, 10) > 0) THEN { Look where you're going }
  56.           cannon(270, scan(270, 10)); { Shoot, as before }
  57.         IF (scan(90, 10) > 0) THEN { Check your rear }
  58.           cannon(90, scan(90, 10)); { Shoot if you see anything }
  59.       END;
  60.       drive(270, 0); { Slow down }
  61.       WHILE (speed > 50) DO ; { Wait for 50 }
  62.  
  63.     UNTIL Dead OR Winner;
  64.  
  65.   END; { End RUNNER Main }
  66.